#!/usr/bin/python

import argparse
import csv
import os
import random
import subprocess

def transformCSV(inputFolder, outputFolder, replicationFactor):
    subprocess.call("mkdir -p %s" % (outputFolder), shell=True)
    for filename in os.listdir(inputFolder):
       if ".pdf" in filename:
           continue
       subprocess.call("./replicate-csv -i %s -o %s -r %d" % (
           os.path.join(inputFolder, filename),
           os.path.join(outputFolder, filename), replicationFactor), shell=True)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description=("Produce plot of data dumped in provided data file")
    )
    parser.add_argument('-i', "--inputFolder", required=True,
                        help="Folder with input CSV files")
    parser.add_argument('-o', "--outputFolder", required=True,
                        help="Folder with output CSV files")
    parser.add_argument('-r', "--replicationFactor", default=10, type=int,
                        help="Number of times to replicate input row in output file")

    cmdLineArgs = parser.parse_args()
    optDict = vars(cmdLineArgs)

    transformCSV(optDict["inputFolder"], optDict["outputFolder"],
                 optDict["replicationFactor"])